<?php
namespace app\model;
use app\BaseModel;
use think\model\concern\SoftDelete;
use app\model\BannerType;

class Banner extends BaseModel
{

    use SoftDelete;
    protected $deleteTime = 'delete_time';
    protected $defaultSoftDelete = '0000-00-00 00:00:00';
    protected $hidden = ['update_time','delete_time','sort','status'];


    public function searchTypeIdAttr($query, $value, $data)
    {
        if (!empty($value)) {
            $query->where('type_id', '=', $value);
        }
    }


    protected function setTypeIdAttr($value, $data)
    {  //当前字段的修改器
        $this->set('type_title', BannerType::where('id', $value)->value('title'));
        return $value;
    }

    protected function setScoreIdAttr($value, $data)
    {
        $this->set('controller', Score::where('id', $data['score_id'])->value('controller') ?? '');
        return $value;
    }





}